package com.hfzy.ihk.facade.linkcall.entity.knowledge;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hfzy.ihk.common.facade.BaseEntity;
import com.hfzy.ihk.facade.linkcall.enums.*;
import com.hfzy.ihk.facade.linkcall.vo.KnowledgeBaseResultVo;
import jdk.nashorn.internal.ir.annotations.Ignore;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.*;

/**
 * Created by Administrator on 2018/7/19.
 * 知识库
 *
 * 也可以理解是一个flowStep
 * @author wws
 */
@Document(indexName = "#{elasticSearchConfig.indexName()}_knowledge_base",shards = 24,replicas = 2, type = "data")
public class KnowledgeBase implements BaseEntity {

    @Id
    private String id;

    private long version;

    /**
     * 标题：客户意图
     * */
    @Field(type = FieldType.Keyword)
    private String title;

    /**问题类型(枚举)
     *  COMMON("c", "一般问题"),
     BUSINESS("b", "业务问题");
     * */
    @Field(type = FieldType.Keyword)
    private KnowledgeType knowledgeType;

    /**关键字列表*/
    private List<String> keyworlds;

    /**问法*/
    private List<String> howAskQuestions;

    /**回答方式*/
    @Field(type = FieldType.Keyword)
    private AnswerType answerType;

    /**
     * 单句问答答案
     * 有多个，随机出一个
     * */
    private LinkedList<String> oneToOneResult;


    /**
     * 单句问答答案
     * 有多个，随机出一个
     * map key 是对应 oneToOneResult集合的值
     * */
    private LinkedHashMap<String,String> resultRecordFile;


    /**
     * 录音文件是否已上传
     * */
    /**是否已上传了录音文件 === 》 如果content(话术) 为空情况下，无须进行上传录音文件*/
    private boolean hadUploadFile = false;


    /**
     * 单句问答对象
     * */
    private List<KnowledgeBaseResultVo> knowledgeBaseResultVos;

    /**回答后操作(枚举)
     *
     STOP("e", "挂机"),
     WAIT_CUSTOMER_ANSWER("o", "等待客户回答"),
     ORIGIN_FLOW("n", "跳转到原主动流程"),
     ASSIGN("a", "跳转到指定主动流程");
     * */
    private AfterAnswerOptionalType afterAnswerOptionalType;

    /**跳转到指定流程*/
    private String skipFlowId;

    /**
     * 多轮会话流程ID
     * */
    @Field(type = FieldType.Keyword)
    private String mutiSessionFlowId;

    private long createUserId;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss" )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss" )
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private Date modTime;

    /**
     * 话术包id
     * 目前知识库和话术包关联
     *
     *
     * 所属知识库类型id
     * 目前 ‘公共知识库’ 通过 知识库类型 相关联
     * 以此作为该类型下的知识库，以达到唯一标识，来 作为 关键字、问法、标题 是否唯一
     * */
    @Field(type = FieldType.Keyword)
    private String packageId;

    /**
     * 所属的类型
     * 如果是公共的 ==》 则packageId 是 指定的行业类型
     * */
    @Field(type = FieldType.Keyword)
    private AffectType affectType;

    /**录音对应的Code 值*/
    private String recordCodeNum;

    private boolean actionCodeBreak=false;//是否可以打断

    private List<KnowledgeUsageType> usageTypes;//用途类型 多选

    private String overrideId;//覆盖掉指定的知识库id

    @Ignore
    private boolean isOverride = false;//是否已经被当前的自定义知识库所覆盖 默认是没有被覆盖

    @Override
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public KnowledgeType getKnowledgeType() {
        return knowledgeType;
    }

    public void setKnowledgeType(KnowledgeType knowledgeType) {
        this.knowledgeType = knowledgeType;
    }

    public List<String> getKeyworlds() {
        return keyworlds;
    }

    public void setKeyworlds(List<String> keyworlds) {
        this.keyworlds = keyworlds;
    }

    public List<String> getHowAskQuestions() {
        return howAskQuestions;
    }

    public void setHowAskQuestions(List<String> howAskQuestions) {
        this.howAskQuestions = howAskQuestions;
    }

    public AnswerType getAnswerType() {
        return answerType;
    }

    public void setAnswerType(AnswerType answerType) {
        this.answerType = answerType;
    }

    public LinkedList<String> getOneToOneResult() {
        return oneToOneResult;
    }

    public void setOneToOneResult(LinkedList<String> oneToOneResult) {
        this.oneToOneResult = oneToOneResult;
    }

    public AfterAnswerOptionalType getAfterAnswerOptionalType() {
        return afterAnswerOptionalType;
    }

    public void setAfterAnswerOptionalType(AfterAnswerOptionalType afterAnswerOptionalType) {
        this.afterAnswerOptionalType = afterAnswerOptionalType;
    }

    public String getMutiSessionFlowId() {
        return mutiSessionFlowId;
    }

    public void setMutiSessionFlowId(String mutiSessionFlowId) {
        this.mutiSessionFlowId = mutiSessionFlowId;
    }

    public long getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(long createUserId) {
        this.createUserId = createUserId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModTime() {
        return modTime;
    }

    public void setModTime(Date modTime) {
        this.modTime = modTime;
    }

    public String getSkipFlowId() {
        return skipFlowId;
    }

    public void setSkipFlowId(String skipFlowId) {
        this.skipFlowId = skipFlowId;
    }

    public LinkedHashMap<String, String> getResultRecordFile() {
        return resultRecordFile;
    }

    public void setResultRecordFile(LinkedHashMap<String, String> resultRecordFile) {
        this.resultRecordFile = resultRecordFile;
    }

    public boolean isHadUploadFile() {
        return hadUploadFile;
    }

    public boolean getHadUploadFile() {
        return hadUploadFile;
    }

    public void setHadUploadFile(boolean hadUploadFile) {
        this.hadUploadFile = hadUploadFile;
    }

    public String getPackageId() {
        return packageId;
    }

    public void setPackageId(String packageId) {
        this.packageId = packageId;
    }

    public String getRecordCodeNum() {
        return recordCodeNum;
    }

    public void setRecordCodeNum(String recordCodeNum) {
        this.recordCodeNum = recordCodeNum;
    }

    public boolean isActionCodeBreak() {
        return actionCodeBreak;
    }

    public void setActionCodeBreak(boolean actionCodeBreak) {
        this.actionCodeBreak = actionCodeBreak;
    }

    public List<KnowledgeUsageType> getUsageTypes() {
        return usageTypes;
    }

    public void setUsageTypes(List<KnowledgeUsageType> usageTypes) {
        this.usageTypes = usageTypes;
    }

    public AffectType getAffectType() {
        return affectType;
    }

    public void setAffectType(AffectType affectType) {
        this.affectType = affectType;
    }

    public String getOverrideId() {
        return overrideId;
    }

    public void setOverrideId(String overrideId) {
        this.overrideId = overrideId;
    }

    public boolean isOverride() {
        return isOverride;
    }

    public void setOverride(boolean override) {
        isOverride = override;
    }

    public List<KnowledgeBaseResultVo> getKnowledgeBaseResultVos() {
        return knowledgeBaseResultVos;
    }

    public void setKnowledgeBaseResultVos(List<KnowledgeBaseResultVo> knowledgeBaseResultVos) {
        this.knowledgeBaseResultVos = knowledgeBaseResultVos;
    }


}
